package com.chenfan.mcn.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.chenfan.mcn.model.McnPage;
import com.chenfan.mcn.model.YearFrameContract;
import com.chenfan.mcn.model.dto.YearFrameContractSearchDTO;
import com.chenfan.mcn.model.vo.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 年框合同 服务类
 * </p>
 *
 * @author lizhejin
 * @since 2021-01-19
 */
public interface YearFrameContractService extends IService<YearFrameContract> {

    /**
     * 新增年框合同
     *
     * @param yearFrameContractVO 请求参数
     * @return {@link Long}
     */
    Long saveData(YearFrameContractVO yearFrameContractVO);

    /**
     * 新增年框合同补充协议
     *
     * @param yearSupplementaryAgreementVO 请求参数
     */
    void addSupplementaryAgreement(YearSupplementaryAgreementVO yearSupplementaryAgreementVO);

    /**
     * 修改年框合同审批状态
     *
     * @param yearFrameContract {@link YearFrameContract}
     * @return {@link Boolean}
     */
    boolean changeStatus(YearFrameContract yearFrameContract);

    /**
     * 根据客户获取折扣审批单
     *
     * @param customerId {@link String}
     * @param selected {@link Boolean}
     * @return {@link List<DiscountApprovalVO>}
     */
    List<DiscountApprovalVO> getDiscountApproval(Long customerId, boolean selected);

    /**
     * 详情
     *
     * @param yearId {@link Long}
     * @return {@link YearFrameContractVO}
     */
    YearFrameContractVO info(Long yearId);

    /**
     * 年框合同分页数据
     *
     * @param page                 {@link }
     * @param yearFrameContractSearchDTO {@link YearFrameContractSearchDTO}
     * @return
     */
    Page<YearFrameVO> getList(McnPage<YearFrameVO> page, YearFrameContractSearchDTO yearFrameContractSearchDTO);

    /**
     * 导出excel
     *
     * @param yearFrameContractSearchDTO {@link YearFrameContractSearchDTO}
     * @param response             {@link HttpServletResponse}
     * @throws Exception 抛出异常
     */
    void exportExcel(YearFrameContractSearchDTO yearFrameContractSearchDTO, HttpServletResponse response) throws Exception;

    /**
     * 获取所有的年框合同
     *
     * @param yearFrameContractSearchDTO {@link YearFrameContractSearchDTO}
     * @return {@link List<YearFrameContractVO>}
     */
    List<YearFrameContractVO> getYearCode(YearFrameContractSearchDTO yearFrameContractSearchDTO);

    /**
     * 自动带出变更前后折扣返点审批单数据
     *
     * @param yearCode {@link String}
     * @return {@link }
     */
    ChangeDiscountApproval getChangeDiscountApproval(String yearCode);

    /**
     * 校验同一客户，同一折扣审批单，非作废状态下是否已经存在年框合同
     * @param targetType   {@link Integer}
     * @param customerId   {@link Long}
     * @param discountCode {@link String}
     * @return {@link YearFrameContract}
     */
    YearFrameContract isExist(Integer targetType, Long customerId, String discountCode);

    /**
     * 客户关联的年框合同信息
     *
     * @param mcnPage    {@link McnPage<CusYearContractVO>}
     * @param customerId {@link Long}
     * @return
     */
    Page<CusYearContractVO> getCusYearContract(McnPage<CusYearContractVO> mcnPage, Long customerId);

    /**
     * 客户下所有年框合同
     *
     * @param customerId 客户id
     * @return 年框合同列表
     */
    List<YearFrameContractVO> getYearContractByCustomerId(Long customerId);

    /**
     * 红人返点合同-选择年框合同
     *
     * @param starId 红人ID
     * @return 年框合同列表
     */
    List<StarRebateContractYearFrameVO> getYearFrameContractForStarRebate(Long starId);
}
